package online.hxstart.code.concurrent.chapter09;

import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;

/**
 * @author huxing
 * @date 2019/7/11 星期四 19:37
 * @describe
 */
public class ClassInit {

  static class Parent {

    static int value = 10;

    static {
      value = 20;
    }
  }


  static class Child extends Parent {

    static int i = value;

  }


  static {
    try {
      System.out.println("The ClassInt static code block will be invoke");
      TimeUnit.SECONDS.sleep(20);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }

  public ClassInit(int a) {

    System.out.println(a);
  }

  public static void main(String[] args) {
    //
//    System.out.println(Child.i);

    IntStream.range(0, 5).forEach(i -> new Thread(String.valueOf(new ClassInit(i))));
  }

}
